package com.besttone.common;

import com.alibaba.druid.filter.stat.MergeStatFilter;
import com.alibaba.druid.wall.WallFilter;
import com.besttone.action.*;
import com.besttone.model.FlashsmsCount;
import com.besttone.model.FlashsmsUser;
import com.besttone.model.ScsButton;
import com.jfinal.config.*;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;

public class MyConfig extends JFinalConfig {

    /**
     * 配置常量
     */
    public void configConstant(Constants me) {
	// 加载数据库配置文件
	loadPropertyFile("sysParameter.properties");
	me.setDevMode(getPropertyToBoolean("devMode", false));
    }

    /**
     * 配置路由
     */
    public void configRoute(Routes me) {
        me.add("/intergrationCountByDay",IntegrationCountByDayAction.class);
        me.add("/businessTypebyDay",BusinessTypeByDayAction.class);
	    me.add("/sms", SmsAction.class);
	    me.add("/receiveReserve", ReceiveReserveAction.class);
	    me.add("/receiveCoupon", ReceiveCouponAction.class);
	    me.add("/shortlink", ShortlinkAction.class);
	    me.add("/intergrationCount", IntegrationCountAction.class);
        me.add("/flashsms", SecurityFlashSmsAction.class);
        me.add("/scsButton",ScsButtonAction.class);
        me.add("/busiCenter",BusinessCenterAction.class);
        me.add("/signalling",SignallingAction.class);
        me.add("/FlashsmsUser",FlashsmsUserDayAction.class);
        me.add("/FlashsmsCount",FlashsmsCountByDayAction.class);
    }
    /**
     * 配置数据库插件 最大连接数默认 100 最小连接数 默认 10
     */
    public void configPlugin(Plugins me) {
        DruidPlugin druidPlugin138 = new DruidPlugin(getProperty("jdbcUrl"),
                getProperty("user"), getProperty("password").trim());
        druidPlugin138.addFilter(new MergeStatFilter());
        druidPlugin138.setMaxActive(150);
        WallFilter wall138 = new WallFilter();
        wall138.setDbType(getProperty("dbType"));
        druidPlugin138.addFilter(wall138);
        me.add(druidPlugin138);
        // 配置ActiveRecord插件
        ActiveRecordPlugin arp138 = new ActiveRecordPlugin("osp",
                druidPlugin138);
        arp138.setShowSql(true);
        me.add(arp138);
        arp138.addMapping("ta_security_scsbutton", ScsButton.class);
        arp138.addMapping("ta_flashsms_user_day", FlashsmsUser.class);
        arp138.addMapping("ta_flash_sms_day", FlashsmsCount.class);
    }
    public void configInterceptor(Interceptors me) {
	// 拦截器
	// me.add(new TxByRegex(".*"));
	// me.add(new LoginInterceptor());
	// me.add(new TxByRegex(".save*"));
	// me.add(new TxByActionKeys("/cash/trans", "/other"));
	// me.add(new TxByActionMethods("save", "update"));
    }

    /**
     * 配置处理器
     */
    public void configHandler(Handlers me) {
    }
    // public static void main(String[] args) {
    // JFinal.start("WebRoot", 80, "/", 5);
    // }
}
